package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.PickGoods;
import com.woniuxy.entity.Unpack;


@Mapper
public interface UnpackMapper {

	@Select("select * from t_unpack ")
	public List<Unpack> all();
	
	@Insert("insert into t_unpack values(default,#{upnu},#{client},#{category},#{quality},#{weight},#{num},#{storehouse},#{time},#{status},#{cgid})")
	public int addUnpack(Unpack unpack);
	
	@Update("update t_unpack set num=#{num},weight=#{weight},quality=#{quality},status=#{status},storehouse=#{storehouse},time=#{time} where upnu=#{upnu}")
	public int updateUnpack(Unpack unpack);
	@Update("update t_unpack set cgid=null where cgid=#{cgid}")
	public int updateCgid(int cgid);
	
	@Select("select * from t_unpack ")
	@Results({
		@Result(id=true,column="upid",property="upid"),
		@Result(column="cgid",property="pickGoods",javaType =PickGoods.class ,one=@One(select="com.woniuxy.mapper.PickGoodsMapper.allunpack"))
	})
	public List<Unpack> allUnpack();
	
	@Update("update t_unpack set status=1 where upid=#{upid}")
	public int updateUnpackStatus(int upid);
	
}
